<template>
  <div class="app-container">
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
          >创建接入点</el-button
        >
      </el-col>
    </el-row>

    <el-table v-loading="loading" :data="enterpriseInfoList">
      <el-table-column label="接入点名称" align="center" prop="applyCode" />
      <el-table-column label="描述" align="center" />
      <el-table-column label="状态" align="center" prop="enterpriseName" />

      <el-table-column label="工具" align="center" prop="brandName" />

      <el-table-column label="公开" align="center">
        <template slot-scope="scope"> </template>
      </el-table-column>

      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" @click="handleAccessPoint(scope.row)"
            >接入点</el-button
          >
          <el-button size="mini" type="text" @click="handleEdit(scope.row)"
            >编辑</el-button
          >
          <el-button size="mini" type="text" @click="handleDelete(scope.row)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <access-dialog :open="accessOpen" @cancel="cancel" />
    <edit
      :open="open"
      :title="title"
      @cancel="cancel"
      @submitForm="submitForm"
      :form="form"
    />
  </div>
</template>

<script>
import accessDialog from "./components/access-dialog";
import edit from "./components/edit";
export default {
  name: "enterpriseInfo",
  data() {
    return {
      // 遮罩层
      loading: false,
      // 总条数
      total: 0,
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 表单参数
      form: {},
      enterpriseInfoList: [{}],
      accessOpen: false,
    };
  },
  components: {
    accessDialog,
    edit,
  },
  created() {},
  methods: {
    cancel() {
      this.open = false;
      this.accessOpen = false;
    },
    handleAccessPoint(row) {
      this.accessOpen = true;
    },
    handleEdit(row) {
      this.title = "编辑接入点";
      this.open = true;
    },
    submitForm() {
      console.log("submitForm");
    },
    async handleDelete(row) {
      const { item } = this;
      try {
        const flag = await this.$modal.confirm("是否确认删除该数据项？");
        if (!flag) return;
        this.$emit("getList");
        this.$modal.msgSuccess("操作成功");
      } catch (error) {
        console.error("操作失败", error);
      }
    },
    handleAdd() {
      this.title = "创建接入点";
      this.open = true;
    },
  },
};
</script>

<style scoped></style>
